<?php

/**
 * Description of DbFaseStap
 *
 * @author GHoogendoorn
 * @version 0.1
 * 
 * Version history
 * 0.1  GHoogendoorn    Initial version
 */
class DbFaseStap extends Database{

    private $fase_step_id;
    private $fase_step;
    private $fase_id;
    private $order;
    
    public function __construct($id='') {
        parent::__construct();
        
        if ( (strlen($id) > 0 ) && $this->dbCheckId ($id, 'fase_stap_id') ){
            $this->selectById($id);
        }
    }

    
    public function getId() {
        return $this->fase_step_id;
    }

    public function setId($fase_step_id) {
        $this->fase_step_id = $fase_step_id;
    }

    public function getFase() {
        return $this->fase_step;
    }

    public function setFase($fase_step) {
        $this->fase_step = $fase_step;
    }

    public function getFaseId() {
        return $this->fase_id;
    }

    public function getOrder() {
        return $this->order;
    }

    public function setOrder($order) {
        $this->order = $order;
    }

        
    public function getFaseStapIdsForFase(){
        
        try {
            $query = "SELECT fase_stap_id,fase_stap_naam FROM `fase_stap` ". 
                        "WHERE `fase_id` = 1 ORDER BY `fase_stap_volgorde`";

            // echo __FILE__ . __LINE__ .": $query<br/>";
            $this->query($query);

            return $this->fetchAll();
        
        } catch (Exception $e){
            trigger_error($e->getMessage());
        }
        
        
    }
    
    private function selectById($id){
        try {
            
            $this->checkId($id, 'fase_stap_id');
            
            $query = "SELECT * FROM `fase_stap` ". 
                        "WHERE `fase_id` = '". $id ."'";

            // echo __FILE__ . __LINE__ .": $query<br/>";
            $this->query($query);

            $result_array = $this->fetchArray();
        
            $this->fase_step_id = $result_array['fase_stap_id'];
            $this->fase_step = $result_array['fase_stap_naam'];
            $this->fase_id = $result_array['fase_id'];
            $this->order = $result_array['fase_stap_volgorde'];
            
            
        } catch (Exception $e){
            trigger_error($e->getMessage());
        }
    }

}

class TestDbFaseStap {

    public function TestDbFaseStap() {
        try {
            $test = new DbFaseStap();
        } catch (Exception $e) {
            echo '<pre>';
            echo $e->getTraceAsString();
            echo '</pre>';
            trigger_error($e->getMessage());
        }
    }

}

?>
